import React, { Component } from 'react'

export default class Child extends Component {
  render() {
    return <div>Child</div>
  }
  handleMouseMove() {
    console.log('mousemove')
  }
  componentDidMount() {
    // 往实例上挂了一个 timer
    this.timer = setInterval(() => console.log(1), 1000)
    document.addEventListener('mousemove', this.handleMouseMove)
  }
  componentWillUnmount() {
    // 1. 清除定时器
    clearInterval(this.timer)
    // 2. 解绑事件
    document.removeEventListener('mousemove', this.handleMouseMove)
    console.log('componentWillUnmount')
  }
}
